
import 'package:flutter/services.dart';

class ChannelUtil{

  static const MethodChannel _navCoreChannel = const MethodChannel('dongci/NavCoreChannel');
  static const MethodChannel _faceSDKChannel = const MethodChannel('com.ios.facesdkplugin');
  static const MethodChannel _ocrSDKChannel = const MethodChannel('com.ios.ocrsdkplugin');
  static const MethodChannel androidNativeChannel = const MethodChannel("com.dognci.framework.plugins/androidNative");

  //打开URL，支持URL跳转
  static void openURL({String url}){
    _navCoreChannel.invokeMethod('openurl', {"url": url});
  }

  //打开AppStore进入对应App
  static void setupApp(){
    String url = "https://apps.apple.com/cn/app/id988370186";
    openURL(url:url);
  }

  //百度地图导航
  static void bdNav(double bLat,double bLon,String bName,double eLat,double eLon,String eName){
    //String url = "baidumap://map/direction?origin=latlng:$bLat,$bLon|name:$bName&destination=latlng:$eLat,$eLon|name:$eName&mode=driving";
    String url = "baidumap://map/direction?destination=latlng:$eLat,$eLon|name:$eName&mode=driving";
    openURL(url:url);
  }

  //打开AppStore进入对应App
  static Future<String> startLiveness() async{
    Map result = await _faceSDKChannel.invokeMethod('startLiveness', {"type":"0"});
    String base64 = result["image"];
    //print(base64);
    return base64;
  }

  //打开AppStore进入对应App
  static Future<Map> startIDCardOCR() async{
    Map result = await _ocrSDKChannel.invokeMethod('startIDCardOCR', {"type":"0"});
    //String base64 = result["image"];
    //print(base64);
    return result;
  }


}